<template>
	<!-- 启动页 -->
	<view></view>
</template>

<script>
export default {
	async onLoad() {
		//启动页停留
		await new Promise((resolve, reject) => {
			setTimeout(() => {
				resolve();
			}, 2000);
		});
		const isFirstOpen = uni.getStorageSync('isFirstOpen');
		// 版本更新
		// #ifdef APP-PLUS
		const { platform } = uni.getSystemInfoSync();
		const { versionCode: oldVersion} = plus.runtime;
		const { versionNum: newVersion, relasenote, url } = await this.request.get('/base/getAPPNewVersionVO/1/' +(platform ==='ios' ? 2 : 1));
		const appid="1530664104"
		if (oldVersion < parseInt(newVersion)) {
			uni.showModal({
				title: '版本更新',
				content: relasenote,
				confirmText: '更新',
				showCancel: false,
				success: function(res) {
					if (platform !== 'ios') {
						uni.navigateTo({
							url: '/pages/user/version-update?downloadUrl=' + url
						});
					} else {
						plus.runtime.launchApplication(
							{
								action: `itms-apps://itunes.apple.com/cn/app/id${appid}?mt=8`
							},
							function(e) {
								console.log('Open system default browser failed: ' + e.message);
							}
						);
					}
				}
			});
			return;
		}
		// #endif
		//首次登录
		if (isFirstOpen !== true) {
			uni.redirectTo({
				url: '../guide/guide'
			});
			return;
		}

		//是否已登录
		if (this.vuex_user === null) {
			uni.redirectTo({
				url: '../login/login'
			});
			return;
		}
		uni.switchTab({
			url: '../home/home'
		});
	}
};
</script>
<style>
page {
	background-color: #ffffff;
	height: 100%;
	overflow: hidden;
}
</style>
<style scoped lang="scss">
view {
	width: 100%;
	height: 100%;
	overflow: hidden;
	background:#fff url(../../static/startUpPage/Android.png) no-repeat center;
	background-size: 100% auto;
}
</style>
